FROM maven:3.8.4-openjdk-17 AS builder
WORKDIR /app
COPY . .
# 调试：查看项目结构
RUN ls -la

RUN mvn install

RUN mvn package -DskipTests -f ruoyi-admin/pom.xml  # 确保构建成功

# 生产阶段
FROM openjdk:17-jdk-slim
WORKDIR /app

# 使用apt-get安装字体依赖（Debian/Ubuntu系统）
RUN apt-get update && apt-get install -y --no-install-recommends \
    libfreetype6 \
    fontconfig \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/ruoyi-admin/target/ruoyi-admin.jar .
CMD ["java", "-jar", "ruoyi-admin.jar"]